﻿package com.amcharts.geom
{
    import com.amcharts.utils.*;
    import flash.display.*;
    import flash.geom.*;

    public class Polygon extends ExtendedSprite
    {
        static const VERSION:String = "1.8.3.1";

        public function Polygon(param1:Array, param2:Array, param3:Array, param4:Array, param5:uint = 0, param6:uint = 0, param7:Number = 0, param8:Number = 1.5708)
        {
            var _loc_10:Number = NaN;
            var _loc_18:Array = null;
            var _loc_19:Matrix = null;
            var _loc_9:* = param3.length;
            if (_loc_9 > 0)
            {
                _loc_18 = new Array();
                _loc_10 = 0;
                while (_loc_10 < _loc_9)
                {
                    
                    _loc_18[_loc_10] = 255 / (param3.length - 1) * _loc_10;
                    if (param4[_loc_10] == undefined)
                    {
                        param4[_loc_10] = param4[(_loc_10 - 1)];
                    }
                    param4[_loc_10] = param4[_loc_10];
                    _loc_10 = _loc_10 + 1;
                }
            }
            var _loc_11:* = Math.min.apply(null, param1);
            var _loc_12:* = Math.max.apply(null, param1);
            var _loc_13:* = Math.min.apply(null, param2);
            var _loc_14:* = Math.max.apply(null, param2);
            var _loc_15:* = _loc_12 - _loc_11;
            var _loc_16:* = _loc_14 - _loc_13;
            this.graphics.clear();
            if (param3.length > 1)
            {
                _loc_19 = new Matrix();
                _loc_19.createGradientBox(_loc_15, _loc_16, param8, _loc_11, _loc_13);
                this.graphics.beginGradientFill(GradientType.LINEAR, param3, param4, _loc_18, _loc_19);
            }
            else
            {
                this.graphics.beginFill(param3[0], param4[0]);
            }
            this.graphics.lineStyle(param5, param6, param7);
            this.graphics.moveTo(param1[0], param2[0]);
            var _loc_17:* = param1.length;
            _loc_10 = 1;
            while (_loc_10 < _loc_17)
            {
                
                this.graphics.lineTo(param1[_loc_10], param2[_loc_10]);
                _loc_10 = _loc_10 + 1;
            }
            this.graphics.endFill();
            return;
        }// end function

    }
}
